#!/usr/bin/env python

import sys


def format_output_all(cnt, cnt_all):
    OUT_TEMPL = "%s\t%5.1f%%"
    rel_cnt = cnt_all and float(cnt)/cnt_all*100 or 0.0
    return OUT_TEMPL % (cnt, rel_cnt)

def format_output_rel(cnt, cnt_all):
    OUT_TEMPL = "%5.1f%%"
    rel_cnt = cnt_all and float(cnt)/cnt_all*100 or 0.0
    return OUT_TEMPL % (rel_cnt,)


def parse_input(source):
    results = {}
    for line in source:
        try:
            cnt, code = line.split()
        except:
            print >> sys.stderr, 'Bad line:', line.strip('\n')
            raise
        code = float(code)
        cnt = int(cnt)
        results[code] = cnt
    return results

def print_results_human(results):
    N_all = sum(results.itervalues())
    print "All:\t\t%s\t%6.2f%%" % (N_all, float(N_all)/N_all*100)
    N_ann = sum(cnt for code, cnt in results.iteritems() if code>=0)
    print "Annotated:\t%s\t%6.2f%%" % (N_ann, float(N_ann)/N_all*100)
    N_noann = sum(cnt for code, cnt in results.iteritems() if code<0)
    print "NoAnnotated:\t%s\t%6.2f%%" % (N_noann, float(N_noann)/N_all*100)        
    print

    N_pred = sum(cnt for code, cnt in results.iteritems() if code>=0 and code != 0.5)
    print "AnnPred:\t%s\t%6.2f%%" % (N_pred, float(N_pred)/N_ann*100)
    N_nopred = results[0.5]
    print "AnnNoPred:\t%s\t%6.2f%%" % (N_nopred, float(N_nopred)/N_ann*100)
    print

    N_pred_exact = 0
    for code in sorted(c for c in results.iterkeys() if c >= 1):        
        N_pred_exact += results[code]
        print "AnnPredEx_%02i:\t%s\t%6.2f%%" % (code, N_pred_exact, float(N_pred_exact)/N_pred*100)
    print

    N_noannpred = results[-1]
    print "NoAnnPred:\t%s\t%6.2f%%" % (N_noannpred, float(N_noannpred)/N_noann*100)
    N_noannnopred = results[-2]
    print "NoAnnNoPred:\t%s\t%6.2f%%" % (N_noannnopred, float(N_noannnopred)/N_noann*100)


def print_results_tsv(results, format_output):
    # All   Annotated   NoAnnotated     AnnPred     AnnNoPred   AnnPredEx_01 AnnPredEx_03 AnnPredEx_05 AnnPredEx_10     NoAnnPred   NoAnnNoPred:
    output = []
    N_all = sum(results.itervalues())
    output.append( '%5i' % N_all )
    N_ann = sum(cnt for code, cnt in results.iteritems() if code>=0)
    output.append( format_output(N_ann, N_all) )
    N_noann = sum(cnt for code, cnt in results.iteritems() if code<0)
    output.append( format_output(N_noann, N_all) )

    N_pred = sum(cnt for code, cnt in results.iteritems() if code>=0 and code != 0.5)
    output.append( format_output(N_pred, N_ann) )
    N_nopred = results[0.5]
    output.append( format_output(N_nopred, N_ann) )

    N_pred_exact = 0
    for code in range(1, 11):
        N_pred_exact += results.get(code, 0)
        if code in (1,3,5,10):
            output.append( format_output(N_pred_exact, N_pred) )

    N_noannpred = results[-1]
    output.append( format_output(N_noannpred, N_noann) )
    N_noannnopred = results[-2]
    output.append( format_output(N_noannnopred, N_noann) )
    
    print ' | '.join(output)


def main():
    results = parse_input(sys.stdin)
    if len(sys.argv) > 1:
        if sys.argv[1] == '--tsv':
            format_output = format_output_rel
        elif sys.argv[1] == '--tsv-all':
            format_output = format_output_all
        print_results_tsv(results, format_output)
    else:
        print_results_human(results)


main()


